<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of mlpunpack</title>
  <meta name="keywords" content="mlpunpack">
  <meta name="description" content="MLPUNPACK  ReBEL MLP neural network weight matrices de-vectorizer.">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../../menu.html">Home</a> &gt;  <a href="#">ReBEL-0.2.7</a> &gt; <a href="#">core</a> &gt; mlpunpack.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../../menu.html"><img alt="<" border="0" src="../../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="menu.html">Index for .\ReBEL-0.2.7\core&nbsp;<img alt=">" border="0" src="../../right.png"></a></td></tr></table>-->

<h1>mlpunpack
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>MLPUNPACK  ReBEL MLP neural network weight matrices de-vectorizer.</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function [W1, B1, W2, B2, W3, B3, W4, B4] = mlpunpack(nodes, wh) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment"> MLPUNPACK  ReBEL MLP neural network weight matrices de-vectorizer.

  This function unpacks the parameters (weights and biases) of ReBEL MLP neural network
  from a single vector into the correct weight and bias matrices as specified by the
  neural network layer descriptor vector, nodes. Only 2,3 and 4 layer networks are supported.

   [W1, B1, W2, B2, W3, B3, W4, B4] = mlpunpack(nodes, wh)

  INPUT
        wh       :   vector of 'vectorized' neural network weights (created with 'nnpack.m')
        nodes    :   MLP neural network layer descriptor vector

  OUTPUT
        W1       :   layer 1 weights
        B1       :   layer 1 biases
        W2       :   layer 2 weights
        B2       :   layer 2 biases
        W3       :   (optional) layer 3 weights
        B3       :   (optional) layer 3 biases
        W4       :   (optional) layer 4 weights
        B4       :   (optional) layer 4 biases


  SEE ALSO:
            <a href="mlppack.html" class="code" title="function [wh, nodes] = mlppack(W1, B1, W2, B2, W3, B3, W4, B4)">mlppack</a>

   Copyright (c) Oregon Health &amp; Science University (2006)

   This file is part of the ReBEL Toolkit. The ReBEL Toolkit is available free for
   academic use only (see included license file) and can be obtained from
   http://choosh.csee.ogi.edu/rebel/.  Businesses wishing to obtain a copy of the
   software should contact rebel@csee.ogi.edu for commercial licensing information.

   See LICENSE (which should be part of the main toolkit distribution) for more
   detail.</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
</ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="mlpff.html" class="code" title="function Y = mlpff(olType, nodes, X, W1, B1, W2, B2, W3, B3, W4, B4)">mlpff</a>	MLPFF  Calculates the output of a ReBEL feed-forward MLP neural network with 2,3 or 4 layers</li><li><a href="mlpjacobian.html" class="code" title="function [J1,J2] = mlpjacobian(jacType, olType, nodes, X, W1, B1, W2, B2, W3, B3, W4, B4)">mlpjacobian</a>	MLPJACOBIAN   Calculates the Jacobian (first partial derivative matrix)</li><li><a href="../.././ReBEL-0.2.7/examples/gssm/gssm_mackey_glass.html" class="code" title="function [varargout] = model_interface(func, varargin)">gssm_mackey_glass</a>	GSSM_MACKEY_GLASS  Generalized state space model for Mackey-Glass chaotic time series</li></ul>
<!-- crossreference -->


<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [W1, B1, W2, B2, W3, B3, W4, B4] = mlpunpack(nodes, wh)</a>
0002 
0003 <span class="comment">% MLPUNPACK  ReBEL MLP neural network weight matrices de-vectorizer.</span>
0004 <span class="comment">%</span>
0005 <span class="comment">%  This function unpacks the parameters (weights and biases) of ReBEL MLP neural network</span>
0006 <span class="comment">%  from a single vector into the correct weight and bias matrices as specified by the</span>
0007 <span class="comment">%  neural network layer descriptor vector, nodes. Only 2,3 and 4 layer networks are supported.</span>
0008 <span class="comment">%</span>
0009 <span class="comment">%   [W1, B1, W2, B2, W3, B3, W4, B4] = mlpunpack(nodes, wh)</span>
0010 <span class="comment">%</span>
0011 <span class="comment">%  INPUT</span>
0012 <span class="comment">%        wh       :   vector of 'vectorized' neural network weights (created with 'nnpack.m')</span>
0013 <span class="comment">%        nodes    :   MLP neural network layer descriptor vector</span>
0014 <span class="comment">%</span>
0015 <span class="comment">%  OUTPUT</span>
0016 <span class="comment">%        W1       :   layer 1 weights</span>
0017 <span class="comment">%        B1       :   layer 1 biases</span>
0018 <span class="comment">%        W2       :   layer 2 weights</span>
0019 <span class="comment">%        B2       :   layer 2 biases</span>
0020 <span class="comment">%        W3       :   (optional) layer 3 weights</span>
0021 <span class="comment">%        B3       :   (optional) layer 3 biases</span>
0022 <span class="comment">%        W4       :   (optional) layer 4 weights</span>
0023 <span class="comment">%        B4       :   (optional) layer 4 biases</span>
0024 <span class="comment">%</span>
0025 <span class="comment">%</span>
0026 <span class="comment">%  SEE ALSO:</span>
0027 <span class="comment">%            mlppack</span>
0028 <span class="comment">%</span>
0029 <span class="comment">%   Copyright (c) Oregon Health &amp; Science University (2006)</span>
0030 <span class="comment">%</span>
0031 <span class="comment">%   This file is part of the ReBEL Toolkit. The ReBEL Toolkit is available free for</span>
0032 <span class="comment">%   academic use only (see included license file) and can be obtained from</span>
0033 <span class="comment">%   http://choosh.csee.ogi.edu/rebel/.  Businesses wishing to obtain a copy of the</span>
0034 <span class="comment">%   software should contact rebel@csee.ogi.edu for commercial licensing information.</span>
0035 <span class="comment">%</span>
0036 <span class="comment">%   See LICENSE (which should be part of the main toolkit distribution) for more</span>
0037 <span class="comment">%   detail.</span>
0038 
0039 <span class="comment">%=============================================================================================</span>
0040 
0041 <span class="keyword">if</span> (nargin ~= 2) error(<span class="string">' [ mlpunpack ] Not enough input arguments.'</span>); <span class="keyword">end</span>
0042 
0043 nLayers = length(nodes)-1;
0044 
0045 
0046 <span class="keyword">switch</span> nLayers
0047 
0048  <span class="keyword">case</span> 2
0049 
0050    numW1 = nodes(1)*nodes(2);
0051    numB1 = nodes(2);
0052    numW2 = nodes(2)*nodes(3);
0053    numB2 = nodes(3);
0054 
0055    W1=zeros(nodes(2),nodes(1));
0056    B1=zeros(nodes(2),1);
0057    W2=zeros(nodes(3),nodes(2));
0058    B2=zeros(nodes(3),1);
0059 
0060    i=0;
0061    j=i+numW1; W1(:) = wh(i+1:j); i=j;
0062    j=i+numB1; B1 = wh(i+1:j); i=j;
0063    j=i+numW2; W2(:) = wh(i+1:j); i=j;
0064    j=i+numB2; B2 = wh(i+1:j);
0065 
0066  <span class="keyword">case</span> 3
0067 
0068    numW1 = nodes(1)*nodes(2);
0069    numB1 = nodes(2);
0070    numW2 = nodes(2)*nodes(3);
0071    numB2 = nodes(3);
0072    numW3 = nodes(3)*nodes(4);
0073    numB3 = nodes(4);
0074 
0075    W1=zeros(nodes(2),nodes(1));
0076    B1=zeros(nodes(2),1);
0077    W2=zeros(nodes(3),nodes(2));
0078    B2=zeros(nodes(3),1);
0079    W3=zeros(nodes(4),nodes(3));
0080    B3=zeros(nodes(4),1);
0081 
0082    i=0;
0083    j=i+numW1; W1(:) = wh(i+1:j); i=j;
0084    j=i+numB1; B1 = wh(i+1:j); i=j;
0085    j=i+numW2; W2(:) = wh(i+1:j); i=j;
0086    j=i+numB2; B2 = wh(i+1:j); i=j;
0087    j=i+numW3; W3(:) = wh(i+1:j); i=j;
0088    j=i+numB3; B3 = wh(i+1:j);
0089 
0090  <span class="keyword">case</span> 4
0091 
0092    numW1 = nodes(1)*nodes(2);
0093    numB1 = nodes(2);
0094    numW2 = nodes(2)*nodes(3);
0095    numB2 = nodes(3);
0096    numW3 = nodes(3)*nodes(4);
0097    numB3 = nodes(4);
0098    numW4 = nodes(4)*nodes(5);
0099    numB4 = nodes(5);
0100 
0101    W1=zeros(nodes(2),nodes(1));
0102    B1=zeros(nodes(2),1);
0103    W2=zeros(nodes(3),nodes(2));
0104    B2=zeros(nodes(3),1);
0105    W3=zeros(nodes(4),nodes(3));
0106    B3=zeros(nodes(4),1);
0107    W4=zeros(nodes(5),nodes(4));
0108    B4=zeros(nodes(5),1);
0109 
0110    i=0;
0111    j=i+numW1; W1(:) = wh(i+1:j); i=j;
0112    j=i+numB1; B1 = wh(i+1:j); i=j;
0113    j=i+numW2; W2(:) = wh(i+1:j); i=j;
0114    j=i+numB2; B2 = wh(i+1:j); i=j;
0115    j=i+numW3; W3(:) = wh(i+1:j); i=j;
0116    j=i+numB3; B3 = wh(i+1:j);
0117    j=i+numW4; W4(:) = wh(i+1:j); i=j;
0118    j=i+numB4; B4 = wh(i+1:j);
0119 
0120 
0121  <span class="keyword">otherwise</span>
0122 
0123   error(<span class="string">' [ mlpunpack ] MLP neural networks with more than 4 layers are not supported.'</span>);
0124 
0125 <span class="keyword">end</span></pre></div>
<hr><address>Generated on Tue 26-Sep-2006 10:36:21 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address>
</body>
</html>